package mapper;

import model.Course;
import model.Teacher;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CourseMapper {
    @Select("select * from course where id=#{id}")
     Course selectByPrimaryKey(int id);
    @Select("select  * from course")
    @Results({
          /*  @Result(column = "teacher_id",property = "teacher",javaType = Teacher.class,
            one = @One(select = "mapper.TeacherMapper.selectByPrimaryKey"))*/
            @Result(column = "id",property = "id",javaType = Integer.class),
            @Result(column = "id",property = "teachers",javaType = List.class,
                    many = @Many(select = "mapper.TeacherCourseMapper.selectByCourseId"))
    })
    List<Course> selectAll();
}
